package cn.tedu.csmall.all.adapter;

import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

import java.util.ArrayList;
import java.util.List;

@SpringBootApplication
@ComponentScan(basePackages = {"cn.tedu.csmall.all","cn.tedu.csmall.commons.exception"})
//在启动类中开启dubbo相关配置注解
@EnableDubbo
public class OrderApplication {
    public static void main(String[] args) {

        SpringApplication.run(OrderApplication.class, args);
        /*List<DegradeRule> degradeRules=new ArrayList<>();
        //添加一个熔断规则
        DegradeRule degradeRule=new DegradeRule();
        //规则对应限制的资源id
        degradeRule.setResource("cartDelete");
        degradeRule.setCount(1);
        degradeRule.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);
        degradeRule.setTimeWindow(10);//如果出现熔断,持续多长时间重试
        degradeRule.setSlowRatioThreshold(0.5);
        degradeRule.setMinRequestAmount(1);
        degradeRule.setStatIntervalMs(10000);//统计的时间范围
        degradeRules.add(degradeRule);
        DegradeRuleManager.loadRules(degradeRules);
   */ }
}
